﻿<UserControl x:Class="TanmiaGrp.GeneralLedger.WinApp.Pages.GroupBrowserView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:loc="clr-namespace:TanmiaGrp.GeneralLedger.WinApp"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="600">
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </UserControl.Resources>

    <Grid Style="{StaticResource ContentRoot}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="20*" />
            <ColumnDefinition Width="6" />
            <ColumnDefinition Width="80*" />
        </Grid.ColumnDefinitions>

        <ScrollViewer Margin="{StaticResource SplitLeft}">
            <StackPanel>
                <Button Content="حذف"
                        Command="{Binding Path=DeleteCommand}" />

                <Button Content="تعديل"
                        Command="{Binding Path=EditCommand}"
                        CommandParameter="{Binding Path=Entities.CurrentItem}" />

                <Button Content="اضافة"
                        Command="{Binding Path=AddCommand}"
                        CommandParameter="{x:Null}" />

                <Button Content="تحديث"
                        Command="{Binding Path=RefreshCommand}" CommandParameter="{x:Static loc:NavigationMoveEnum.KeepCurrent}"/>

                <Button Content="الصفحة الأولى"
                        Command="{Binding Path=GoToForthPageCommand}"
                        CommandParameter="{x:Static loc:NavigationMoveEnum.First}" />

                <Button Content="الصفحة السابقة"
                        Command="{Binding Path=GoToForthPageCommand}"
                        CommandParameter="{x:Static loc:NavigationMoveEnum.Previous}" />

                <Button Content="الصفحة التالية"
                        Command="{Binding Path=GoToBackPageCommand}"
                        CommandParameter="{x:Static loc:NavigationMoveEnum.Next}" />

                <Button Content="الصفحة الأخيرة"
                        Command="{Binding Path=GoToBackPageCommand}"
                        CommandParameter="{x:Static loc:NavigationMoveEnum.Last}" />

                <Button Name="btnPopout"
                        Content="فتح في نافذة جديدة"
                        Click="OnPopout" />

                <TextBox Text="{Binding Path=PageNumber}"
                         IsReadOnly="True" />
                <Button Content="اغلاق"
                        Command="{Binding Path=CloseCommand}"
                        CommandParameter="{Binding RelativeSource={RelativeSource Self}}" />
            </StackPanel>
        </ScrollViewer>
        <GridSplitter Grid.Column="1" />
        <Grid Grid.Column="2"
              Margin="{StaticResource SplitRight}">

            <DataGrid ItemsSource="{Binding Path=EntitiesTask.Result.Entities}"
                      CanUserAddRows="False"
                      CanUserDeleteRows="False"
                      CanUserResizeRows="False"
                      IsSynchronizedWithCurrentItem="True"
                      FontFamily="Tahoma"
                      AutoGenerateColumns="False">

                <DataGrid.ItemContainerStyle>
                    <Style TargetType="DataGridRow">
                        <Setter Property="IsSelected"
                                Value="{Binding Path=IsSelected, Mode=TwoWay}" />
                    </Style>
                </DataGrid.ItemContainerStyle>
                <DataGrid.Columns>

                    <DataGridTextColumn Header="رقم المجموعة"
                                        Binding="{Binding Path=GroupID}"
                                        IsReadOnly="True" />

                    <DataGridTextColumn Header="اسم المجموعة"
                                        Binding="{Binding Path=GroupName}"
                                        IsReadOnly="True" />

                    <DataGridTextColumn Header="فعال؟"
                                        Binding="{Binding Path=IsEnabled}"
                                        IsReadOnly="True" />

                    <DataGridTextColumn Header="ملاحظات"
                                        Binding="{Binding Path=Notes}"
                                        IsReadOnly="True" />

                    <DataGridTextColumn Header="تاريخ الإنشاء"
                                        Binding="{Binding Path=CreateDate}"
                                        IsReadOnly="True" />
                </DataGrid.Columns>
            </DataGrid>

            <Label Content="Loading..."
                   VerticalContentAlignment="Center"
                   HorizontalContentAlignment="Center"
                   Background="White"
                   Opacity=".7"
                   Visibility="{Binding Path=EntitiesTask.IsNotCompleted, Converter={StaticResource BooleanToVisibilityConverter}}" />
        </Grid>
    </Grid>
</UserControl>
